import request from "@/utils/request";

const CODEINFO_BASE_URL = "/api/v1/codeInfos";

const CodeInfoAPI = {
    /** 获取股票代码1分页数据 */
    getPage(queryParams?: CodeInfoPageQuery) {
        return request<any, PageResult<CodeInfoPageVO[]>>({
            url: `${CODEINFO_BASE_URL}/page`,
            method: "get",
            params: queryParams,
        });
    },
    /**
     * 获取股票代码1表单数据
     *
     * @param id CodeInfoID
     * @returns CodeInfo表单数据
     */
    getFormData(id: number) {
        return request<any, CodeInfoForm>({
            url: `${CODEINFO_BASE_URL}/${id}/form`,
            method: "get",
        });
    },

    /** 添加股票代码1*/
    add(data: CodeInfoForm) {
        return request({
            url: `${CODEINFO_BASE_URL}`,
            method: "post",
            data: data,
        });
    },

    /**
     * 更新股票代码1
     *
     * @param id CodeInfoID
     * @param data CodeInfo表单数据
     */
     update(id: number, data: CodeInfoForm) {
        return request({
            url: `${CODEINFO_BASE_URL}/${id}`,
            method: "put",
            data: data,
        });
    },

    /**
     * 批量删除股票代码1，多个以英文逗号(,)分割
     *
     * @param ids 股票代码1ID字符串，多个以英文逗号(,)分割
     */
     deleteByIds(ids: string) {
        return request({
            url: `${CODEINFO_BASE_URL}/${ids}`,
            method: "delete",
        });
    }
}

export default CodeInfoAPI;

/** 股票代码1分页查询参数 */
export interface CodeInfoPageQuery extends PageQuery {
}

/** 股票代码1表单对象 */
export interface CodeInfoForm {
    /** 代码 */
    code?:  string;
    /** 名称 */
    name?:  string;
}

/** 股票代码1分页对象 */
export interface CodeInfoPageVO {
    id?: number;
    /** 代码 */
    code?: string;
    /** 名称 */
    name?: string;
}
